<html>
<head><meta charset="utf-8"><title>vscode bad_actor · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/vscode.20bad_actor.html">vscode bad_actor</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="239631586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/vscode%20bad_actor/near/239631586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bynx <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/vscode.20bad_actor.html#239631586">(May 20 2021 at 17:42)</a>:</h4>
<p>Wondering if anyone has seen this yet (code exec via macro expansion when loading a crate in VSCode)?</p>
<p><a href="https://github.com/lucky/bad_actor_poc">https://github.com/lucky/bad_actor_poc</a></p>



<a name="239631749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/vscode%20bad_actor/near/239631749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/vscode.20bad_actor.html#239631749">(May 20 2021 at 17:43)</a>:</h4>
<p>of course :)</p>



<a name="239631800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/vscode%20bad_actor/near/239631800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bynx <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/vscode.20bad_actor.html#239631800">(May 20 2021 at 17:44)</a>:</h4>
<p>Cool cool haha. I figured - but just wanted to double check</p>



<a name="239667886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/vscode%20bad_actor/near/239667886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/vscode.20bad_actor.html#239667886">(May 20 2021 at 22:21)</a>:</h4>
<p>And see also: <a href="https://rust-analyzer.github.io/manual.html#security">https://rust-analyzer.github.io/manual.html#security</a></p>



<a name="239779016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/vscode%20bad_actor/near/239779016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Frampton <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/vscode.20bad_actor.html#239779016">(May 21 2021 at 16:35)</a>:</h4>
<p>It could be interesting to look at the workspace trust feature of vscode <a href="https://github.com/microsoft/vscode/issues/120251">https://github.com/microsoft/vscode/issues/120251</a></p>



<a name="239779186"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/vscode%20bad_actor/near/239779186" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/vscode.20bad_actor.html#239779186">(May 21 2021 at 16:36)</a>:</h4>
<p>yeah, that seems like a good solution</p>



<a name="239779209"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/vscode%20bad_actor/near/239779209" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/vscode.20bad_actor.html#239779209">(May 21 2021 at 16:36)</a>:</h4>
<p>is it exposed via LSP?</p>



<a name="239780162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/vscode%20bad_actor/near/239780162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Frampton <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/vscode.20bad_actor.html#239780162">(May 21 2021 at 16:44)</a>:</h4>
<p>I don't know the details, but I am happy to help find out. I might go ahead and get an issue created in <a href="https://github.com/rust-analyzer/rust-analyzer">https://github.com/rust-analyzer/rust-analyzer</a></p>



<a name="239781734"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/vscode%20bad_actor/near/239781734" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Frampton <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/vscode.20bad_actor.html#239781734">(May 21 2021 at 16:57)</a>:</h4>
<p>It looks fairly simple to just add the capability setting to always require trust, which might be the right approach for now. But in theory it might be possible to support the limited mode and provide some functionality.</p>



<a name="239781977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/vscode%20bad_actor/near/239781977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/vscode.20bad_actor.html#239781977">(May 21 2021 at 16:59)</a>:</h4>
<p>implementation-wise the untrusted mode would basically require us to never run any external commands</p>



<a name="239782308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/vscode%20bad_actor/near/239782308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Frampton <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/vscode.20bad_actor.html#239782308">(May 21 2021 at 17:01)</a>:</h4>
<p>I am guessing it would be possible to have a mode that provided intellisense for a project with no <a href="http://build.rs">build.rs</a> or proc_macros, but it would require some care to make sure it was done right.</p>



<a name="239783148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/vscode%20bad_actor/near/239783148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/vscode.20bad_actor.html#239783148">(May 21 2021 at 17:07)</a>:</h4>
<p>what if r-a would do <code>std::env::remove_var("PATH")</code>? that would make it impossible to invoke most external programs. ah, but I guess Windows searches the current directory first</p>



<a name="239783369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/vscode%20bad_actor/near/239783369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/vscode.20bad_actor.html#239783369">(May 21 2021 at 17:09)</a>:</h4>
<p>Impossible to invoke most external programs, apart from literally every external program just by passing in an absolute path.</p>



<a name="239783398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/vscode%20bad_actor/near/239783398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/vscode.20bad_actor.html#239783398">(May 21 2021 at 17:09)</a>:</h4>
<p>yes, but that doesn't happen by accident</p>



<a name="239783497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/vscode%20bad_actor/near/239783497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/vscode.20bad_actor.html#239783497">(May 21 2021 at 17:10)</a>:</h4>
<p>I'm trying to safeguard against an accidental <code>cargo</code> invocation or something similar while in untrusted mode</p>



<a name="239791611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/vscode%20bad_actor/near/239791611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Frampton <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/vscode.20bad_actor.html#239791611">(May 21 2021 at 18:13)</a>:</h4>
<p>In any case, I think once you enable the trusted workspaces feature the default is to require trust to run rust-analyzer. So it might be that we don't really need to do anything here unless we want to support the limited mode. Though we could add the option in the package.json to make that explicit.</p>



<a name="239843217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/vscode%20bad_actor/near/239843217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/vscode.20bad_actor.html#239843217">(May 22 2021 at 04:30)</a>:</h4>
<p><span class="user-mention silent" data-user-id="274417">Daniel Frampton</span> <a href="#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/vscode.20bad_actor/near/239782308">said</a>:</p>
<blockquote>
<p>I am guessing it would be possible to have a mode that provided intellisense for a project with no <a href="http://build.rs">build.rs</a> or proc_macros, but it would require some care to make sure it was done right.</p>
</blockquote>
<p>That would provide no <code>rustc</code> diagnostics either.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>